package com.hacpai.android.md.model.entity;

import com.google.gson.annotations.SerializedName;

import com.hacpai.android.md.model.api.ApiDefine;
import com.hacpai.android.md.util.FormatUtils;
import org.joda.time.DateTime;

import java.util.List;

public class Comment {

    private String commentArticlePermalink;

    private String commentAuthorId;

    @SerializedName("comment_name")
    private String commentAuthorName;

    private String commentAuthorThumbnailURL;

    private String commentAuthorURL;

    private int commentBadCnt;

    private String commentContent;

    private long commentCreateTime;

    private int commentGoodCnt;

    private String commentOnArticleId;

    private String commentOriginalCommentId;

    private int commentReplyCnt;

    private String commentSharpURL;

    private String commentUA;

    private Author commenter;

    private String oId;

    @SerializedName("timeAgo")
    private String timeAgo;


//以下是Comments API内容
    private String commentArticleAuthorName;
    private String commentArticleAuthorThumbnailURL;
    private int commentArticlePerfect;
    private String commentArticleTitle;

    public String getCommentArticleAuthorName() {
        return commentArticleAuthorName;
    }

    public void setCommentArticleAuthorName(String commentArticleAuthorName) {
        this.commentArticleAuthorName = commentArticleAuthorName;
    }

    public String getCommentArticleAuthorThumbnailURL() {
        return commentArticleAuthorThumbnailURL;
    }

    public void setCommentArticleAuthorThumbnailURL(String commentArticleAuthorThumbnailURL) {
        this.commentArticleAuthorThumbnailURL = commentArticleAuthorThumbnailURL;
    }

    public int getCommentArticlePerfect() {
        return commentArticlePerfect;
    }

    public void setCommentArticlePerfect(int commentArticlePerfect) {
        this.commentArticlePerfect = commentArticlePerfect;
    }

    public String getCommentArticleTitle() {
        return commentArticleTitle;
    }

    public void setCommentArticleTitle(String commentArticleTitle) {
        this.commentArticleTitle = commentArticleTitle;
    }

    public String getCommentArticlePermalink() {
        return commentArticlePermalink;
    }

    public void setCommentArticlePermalink(String commentArticlePermalink) {
        this.commentArticlePermalink = commentArticlePermalink;
    }

    public String getCommentAuthorId() {
        return commentAuthorId;
    }

    public void setCommentAuthorId(String commentAuthorId) {
        this.commentAuthorId = commentAuthorId;
    }

    public String getCommentAuthorName() {
        return commentAuthorName;
    }

    public void setCommentAuthorName(String commentAuthorName) {
        this.commentAuthorName = commentAuthorName;
    }

    public String getCommentAuthorThumbnailURL() {
        return commentAuthorThumbnailURL;
    }

    public void setCommentAuthorThumbnailURL(String commentAuthorThumbnailURL) {
        this.commentAuthorThumbnailURL = commentAuthorThumbnailURL;
    }

    public String getCommentAuthorURL() {
        return commentAuthorURL;
    }

    public void setCommentAuthorURL(String commentAuthorURL) {
        this.commentAuthorURL = commentAuthorURL;
    }

    public int getCommentBadCnt() {
        return commentBadCnt;
    }

    public void setCommentBadCnt(int commentBadCnt) {
        this.commentBadCnt = commentBadCnt;
    }

    public String getCommentContent() {
        return commentContent;
    }

    public void setCommentContent(String commentContent) {
        this.commentContent = commentContent;
        contentHtml = null ;//清除Html渲染缓存
    }

    public long getCommentCreateTime() {
        return commentCreateTime;
    }

    public void setCommentCreateTime(long commentCreateTime) {
        this.commentCreateTime = commentCreateTime;
    }

    public int getCommentGoodCnt() {
        return commentGoodCnt;
    }

    public void setCommentGoodCnt(int commentGoodCnt) {
        this.commentGoodCnt = commentGoodCnt;
    }

    public String getCommentOnArticleId() {
        return commentOnArticleId;
    }

    public void setCommentOnArticleId(String commentOnArticleId) {
        this.commentOnArticleId = commentOnArticleId;
    }

    public String getCommentOriginalCommentId() {
        return commentOriginalCommentId;
    }

    public void setCommentOriginalCommentId(String commentOriginalCommentId) {
        this.commentOriginalCommentId = commentOriginalCommentId;
    }

    public int getCommentReplyCnt() {
        return commentReplyCnt;
    }

    public void setCommentReplyCnt(int commentReplyCnt) {
        this.commentReplyCnt = commentReplyCnt;
    }

    public String getCommentSharpURL() {
        return commentSharpURL;
    }

    public void setCommentSharpURL(String commentSharpURL) {
        this.commentSharpURL = commentSharpURL;
    }

    public String getCommentUA() {
        return commentUA;
    }

    public void setCommentUA(String commentUA) {
        this.commentUA = commentUA;
    }

    public Author getCommenter() {
        return commenter;
    }

    public void setCommenter(Author commenter) {
        this.commenter = commenter;
    }

    public String getoId() {
        return oId;
    }

    public void setoId(String oId) {
        this.oId = oId;
    }

    public String getTimeAgo() {
        return timeAgo;
    }

    public void setTimeAgo(String timeAgo) {
        this.timeAgo = timeAgo;
    }

    /**
     * Html渲染缓存
     */

    @SerializedName("content_html")
    private String contentHtml;

    public String getContentHtml() {
        if (contentHtml == null) {
            if (ApiDefine.MD_RENDER) {
                contentHtml = FormatUtils.handleHtml(commentContent);
            } else {
                contentHtml = FormatUtils.handleHtml(FormatUtils.renderMarkdown(commentContent));
            }
        }
        return contentHtml;
    }

    public void setContentFromLocal(String content) {
        if (ApiDefine.MD_RENDER) {
            this.commentContent = FormatUtils.renderMarkdown(content);
        } else {
            this.commentContent = content;
        }
        contentHtml = null; // 清除已经处理的Html渲染缓存
    }

}
